﻿using Orleans;
using Pay.Core.exception;
using Pay.Model.Dto;
using Pay.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace Pay.Api.Controllers
{

    [RoutePrefix("api/pay")]
    public class PayController : BaseController
    {
        /// <summary>
        /// 支付接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Route("pay"), HttpPost]
        public async Task<PayOutput> Pay(PayInput input)
        {
            if (input == null)
            {
                throw new LotException("请求参数不能为空");
            }

            var payService = GrainClient.GrainFactory.GetGrain<IPayService>(input.mch_code);
            return await payService.CreatePayOrder(input);
        }
    }
}